import axios from "axios";

// 创建 axios 实例
const service = axios.create({
  baseURL:'/index.php/Retail/',
  timeout: 50000,
});

// 请求拦截器
service.interceptors.request.use(
  (config) => {
    // const accessToken = localStorage.getItem("accessToken");
    // if (accessToken) {
    //   config.headers.Authorization = accessToken;
    // }
    config.headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
    return config;
  },
  (error) => {
    return Promise.reject(error);
  }
);

// 响应拦截器
service.interceptors.response.use(
  (response) => {
    // const { code, msg } = response.data;
    // if (code === "00000") {
    //   return response.data;
    // }
    // ElMessage.error(msg || "系统出错");
    // return Promise.reject(new Error(msg || "Error"));
    return response.data;
  },
  (error) => {
   
    return Promise.reject(error.message);
  }
);

// 导出 axios 实例
export default service;
